<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>个人信息</title>
    <link rel="stylesheet" type="text/css" href="../../static/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/layui_admin/css/admin.css"/>
</head>
<body>
<div class="layui-tab page-content-wrap">
    <ul class="layui-tab-title">
        <li class="layui-this">查看资料</li>
        <li>修改密码</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <table class="layui-table" lay-even="" lay-skin="nob">
                <colgroup>
                    <col width="100px">
                    <p style="text-align: center">{{ error }}</p>
                    <col width="80%">
                </colgroup>
                <thead>
                <th>ID</th>
                <th>{{ user.Id }}</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>电话</td>
                    <td>{{ user.Tel_Number }}</td>
                </tr>
                <tr>
                    <td>权限</td>
                    {% if user.Role == 'admin' %}
                        <td>管理员</td>
                    {% endif %}
                    {% if user.Role == 'guest' %}
                        <td>用户</td>
                    {% endif %}
                </tr>
                </tbody>
            </table>
        </div>


        <div class="layui-tab-item">
            <form method="post" class="layui-form" style="width: 90%;padding-top: 20px;" action="{{ url_for('login.change_password') }}">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名：</label>
                    <div class="layui-input-block">
                        {{ form.tel_number(class="layui-input layui-disabled", value=user.Tel_Number) }}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">旧密码：</label>
                    <div class="layui-input-block">
                        {{ form.old_password(placeholder="请输入您的旧密码", autocomplete="off", class="layui-input") }}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码：</label>
                    <div class="layui-input-block">
                        {{ form.password1(placeholder="请输入您的新密码", autocomplete="off", class="layui-input") }}
                        {% for i in form.password1.errors %}
                            <small>{{ i }}</small>
                        {% endfor %}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">重复密码：</label>
                    <div class="layui-input-block">
                        {{ form.password2(placeholder="请再一次输入您的新密码", autocomplete="off", class="layui-input") }}
                        {% for i in form.password2.errors %}
                            <small>{{ i }}</small>
                        {% endfor %}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        {{ form.submit(class="layui-btn layui-btn-normal") }}
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="../../static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
    //Demo
    layui.use(['form', 'element'], function () {
        var form = layui.form();
        var element = layui.element();
        form.render();
        //监听信息提交
        form.on('submit(adminInfo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
        //监听密码提交
        form.on('submit(adminPassword)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
</body>
</html>